import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/Book/SearchBook',
    method: 'get',
    params: query
  })
}

export function fetchArticle(id) {
  return request({
    url: '/vue-element-admin/article/detail',
    method: 'get',
    params: { id }
  })
}

export function fetchPv(pv) {
  return request({
    url: '/vue-element-admin/article/pv',
    method: 'get',
    params: { pv }
  })
}

export function createArticle(data) {
  return request({
    url: '/Book/AddTran',
    method: 'post',
    data
  })
}

export function updateArticle(data) {
  return request({
    url: '/Book/Update',
    method: 'post',
    data
  })
}

export function deleteArticle(bookID) {
  return request({
    url: '/Book/Delete',
    method: 'post',
    params: { bookID }
  })
}

export function deleteFile(imageUrl) {
  return request({
    url: '/Stock/DeleteFile',
    method: 'post',
    params: { imageUrl }
  })
}

export function updateStock(data) {
  return request({
    url: '/Stock/Update',
    method: 'post',
    data
  })
}

export function getId() {
  return request({
    url: '/Book/GetId',
    method: 'get'
  })
}
